Merged
Conversation
neSpecc
reviewed
Oct 16, 2025
neSpecc
reviewed
Oct 16, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces LRU-based memoization for the JavaScript worker to reduce database calls and improve performance when processing source maps and function context extraction. The implementation uses a custom decorator with configurable cache size and TTL.
- Adds a new
@memoizedecorator with LRU cache support and hashing strategies - Updates crypto utility to support Blake2b hashing for large JSON objects
- Applies memoization to
loadSourceMapFileandgetFunctionContextmethods
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| lib/memoize/index.ts | New LRU-based memoization decorator with hash and concat key strategies |
| lib/utils/crypto.ts | Enhanced hash function with Blake2b support and configurable digest formats |
| workers/javascript/src/index.ts | Applied memoization to source map loading and function context methods |
| workers/javascript/tests/index.test.ts | Added comprehensive tests for memoization behavior and GridFS mocking |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
neSpecc
reviewed
Oct 19, 2025
neSpecc
reviewed
Oct 20, 2025
neSpecc
reviewed
Oct 21, 2025
neSpecc
reviewed
Oct 27, 2025
neSpecc
reviewed
Oct 27, 2025
Co-authored-by: Peter <specc.dev@gmail.com>
Co-authored-by: Peter <specc.dev@gmail.com>
neSpecc
previously approved these changes
Oct 29, 2025
neSpecc
reviewed
Oct 30, 2025
neSpecc
approved these changes
Nov 1, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
We need to cache large json objects to decrease number db calls and to reduce cpu and memory usage
Solution
Use lru cache in band with hashed objects as a keys
Why lru?
Why crypto module is changed?
blake2b512cause it is prefered for large json objects hashing and it is presented in default js crypto lib seeTodo
lodash.memoizelib could be replaced with this implementationRisks
all of the risks could be solved by the configuration of the cache max elements (i've set to 50 just for example, should be descussed), maybe we can use
maxSizeof thelru-cacheand allow dynamically decide whenever to add a new object to the cache or notalso ttl value should be discussed, but it is placed in env